# Maintainer: David Runge <dvzrv@archlinux.org>

pkgname=mkinitcpio-systemd-tool
pkgver=38
pkgrel=2
pkgdesc="Provisioning tool for systemd in initramfs (systemd-tool)"
arch=(any)
url="https://github.com/random-archer/mkinitcpio-systemd-tool"
license=(Apache-2.0)
depends=(
  bash
  mkinitcpio
  systemd
)
optdepends=(
  'busybox: for initrd-tinysshd.service'
  'cryptsetup: for initrd-cryptsetup.service'
  'dropbear: for initrd-dropbear.service'
  'mc: for initrd-debug-progs.service'
  'nftables: for initrd-nftables.service'
  'tinyssh: for initrd-tinysshd.service'
)
conflicts=(
  mkinitcpio-dropbear
  mkinitcpio-tinyssh
)
backup=(
  etc/$pkgname/config/crypttab
  etc/$pkgname/config/fstab
  etc/$pkgname/config/initrd-nftables.conf
  etc/$pkgname/config/initrd-util-usb-hcd.conf
  etc/$pkgname/config/ntp.conf
  etc/$pkgname/$pkgname.conf
  etc/$pkgname/network/initrd-network.network
)
source=(
  $url/archive/v$pkgver/$pkgname-v$pkgver.tar.gz
  $pkgname-38-initrdpath.patch::https://github.com/random-archer/mkinitcpio-systemd-tool/commit/2df293ebebfc042588b995b5454d8eb856602c88.patch
)
install=$pkgname.install
sha512sums=('2cddc1a56217490b203b0412ea85f2aaf304514ec73ed2bf9aff50ab97248859e18e581a86d519599762189f36f634634d2250ece753d474056ca8079624d1dc'
            '56248f1b93b00a52c5d90744a6e8c99c8fb89286e523fa73091d93d2476aca2604cb78357ae5625cb8dddd2e3aa1f33161bb468d4e7984d86fb9a2642614e4b2')
b2sums=('d413543030f60f64c38e2a7702cfc369e03cbf2ef47a3c23c982526762a90b3d9df2fc96e956039522cc389674e6809cdc8b416de00292fe4993d831af985adf'
        '85ea55641ebab733be5846407598d4d0a4ffa8bf2f80d7677e64e5e89ca1d02d2e8d0360e3228640110928b5dd2af162c9311cfc18770682d059c5e2dbd0f32d')

prepare() {
  patch -Np1 -d $pkgname-$pkgver -i ../$pkgname-38-initrdpath.patch
}

package() {
  make DESTDIR="$pkgdir/" PREFIX=/usr install -C $pkgname-$pkgver
}
